﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Omega.Game.Framework
{

    [Serializable]
    public  class Tilemap
    {
        public List<Layer> Layers { get; set; }

        [NonSerialized]
        //public Dictionary<String , Texture2D> TilesetTextures;


        private int With;
        private int Height;

        public Tilemap( int widht , int height )
        {
            this.With = widht;
            this.Height = height;

            this.Layers = new List<Layer>( 3 );

            for ( int i = 0 ; i < 3 ; i++ )
            {
                Layers.Add( new Layer( this , widht , height , ( float )( i / 100.0f ) ) );
            }

            //this.TilesetTextures = new Dictionary<string , Texture2D>( );
        }

        internal void Resize( int newX , int newY )
        {
            this.With = newX;
            this.Height = newY;

            for ( int layerdeph = 0 ; layerdeph < 3 ; layerdeph++ )
            {
                Layers[ layerdeph ].Resize( newX , newY );
            }

        }
        public virtual void Update( int x , int y )
        {

            //int grWidth = Graphics.Runtime.Width;
            //int grHeight = Graphics.Runtime.Height;
            //int SafeAreaWidth = ( grWidth - ( int )Graphics.Runtime.Camera.ViewPosition.X ) / 32 + 1;
            //int SafeAreaHeight = ( grHeight - ( int )Graphics.Runtime.Camera.ViewPosition.Y ) / 32 + 1;

            //for ( int layerdeph = 0 ; layerdeph < 3 ; layerdeph++ )
            //{
            //    this.Layers[ layerdeph ].Update( null );
            //}
        }
        public void Dispose( )
        {
            for ( int layerdeph = 0 ; layerdeph < 3 ; layerdeph++ )
            {
                Layers[ layerdeph ].Dispose( );

            }
        }

        internal void Load( )
        {

            //TilesetTextures = new Dictionary<string , Texture2D>( );
            //for ( int layerdeph = 0 ; layerdeph < 3 ; layerdeph++ )
            //{
            //    Layers[ layerdeph ].Load( );
            //}

        }

        //public Texture2D GetTexture( String TextureName , int tileId )
        //{

        //    if ( TilesetTextures.ContainsKey( TextureName ) ) return TilesetTextures[ TextureName ];

        //    string key = TextureName;

        //    Texture2D tex = GraphicsContent.LoadTextureFromFile( (tileId == 0 ? GameEnvironment.TilesetsPath : GameEnvironment.AutotilesPath )  + key );
        //    TilesetTextures.Add( key , tex );

        //    return TilesetTextures[ key ];
        //}


    }

}
